<%@page import="models.AutoSite"%>
<%@page import="helpers.StringHelper"%>
<%@page import="java.util.ArrayList"%>
<%@page import="models.User"%>
<%@page import="models.Blog"%>
<%@page import="java.util.TreeMap"%>
<%
	String success = (String) request.getAttribute("success");
	Blog blog = (Blog) request.getAttribute("blog");
	ArrayList<AutoSite> sites = (ArrayList<AutoSite>) request.getAttribute("sites");
	User user = (User) request.getAttribute("user");
%>

<jsp:include page="/layouts/header.jsp">
	<jsp:param name="title" value="" />
	<jsp:param name="description" value="" />
	<jsp:param name="keywords" value="" />
	<jsp:param name="page" value="home" />
</jsp:include>

<div id="userform" class="clearafter">
	<h1>View Blog</h1><hr/>
	<div class="submitlink">
		<form method="post" action="" name="submitlink">
			<%=success != null ? "<p class=\"msg-success\">" + success + "</p>" : "" %>
			<a onclick="javascript:if(!confirm('Do you want delete ?'))return false;" style="font-size: 20px;" href="/delete-blog/<%=blog.getBlogId()%>">Delete</a>
			<p>
				<label> 
					Username
					<br /> 
					<b class="font-24"><%=user.getGmail() %></b>
					<br />
				</label>
			</p>
			<p>
				<label> 
					BlogSpot ID
					<br /> <b class="font-24"><%=blog.getBlogId() != null ? blog.getBlogId() : ""%></b>
					<br />
				</label>
			</p>
			<p>
				<label> 
					Blog Name
					<br /> <b class="font-24"><%=blog.getBlogName() != null ? blog.getBlogName() : ""%></b>
					<br />
				</label>
			</p>
			<p>
				<label> 
					Your Username of Blogger
					<br /> <b class="font-24"><%=blog.getUsername() != null ? blog.getUsername() : ""%></b>
					<br />
				</label>
			</p>
			<p>				
				<label> 
					Your Password of Blogger
					<br /> <b class="font-24"><%=blog.getPassword() != null ? blog.getPassword() : ""%></b>
					<br />
				</label>
			</p>
			<p>
				<label> 
					Category
					<br /> <b class="font-24"><%=!blog.getCategories().isEmpty() ? StringHelper.listToString(blog.getCategories(), ",") : ""%></b>
					<br />
				</label>
			</p>
			<p>
				<label> 
					Maximum site in a blog: 
					<br /> <b class="font-24"><%=blog.getLimitSite()%></b>
					<br />
				</label>
			</p>
			<div id='load-field'>
				
			</div>
		</form>
	</div>
	
	<div class="howdy">
		<h2 class="title">Hi, <%=user.getName() != null ? user.getName() : "" %></h2>
		<ul class="option">
			<li><a href="/add-blog">Add blog</a></li>
			<li><a href="/edit-blog/<%=blog.getBlogId()%>">Edit Blog</a></li>
			<li><a href="/get-content?blogId=<%=blog.getBlogId()%>">Get Special Content</a></li>
			<li><a href="/view-profile">View profile</a></li>
			<li><a href="/logout">Logout</a></li>
		</ul>
		
		<h2 class="title" style="padding-top: 20px;">List sites</h2>
		<div class="listlink">
			<ul>
				<% for (int i = 0; i < sites.size(); i++) { %>
					<li> - <a href="/view-site?siteId=<%=sites.get(i).getId()%>"><%=sites.get(i).getSite() %></a></li>
				<% } %>
			</ul>
		</div>
	</div>
	<div class="clearbreak"></div>
	<hr />
	<div class="checkresult">
		
	</div>
</div>